from appium import webdriver
import unittest
from appium.webdriver.common.appiumby import AppiumBy


class AppiumTestCase(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls):
        desired_caps = dict(
            deviceName='127.0.0.1',
            platformName='Android',
            appPackage='com.iBookStar.activityOff',
            appActivity='com.iBookStar.activityOff.Splash'
        )
        cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        cls.driver.implicitly_wait(30)

    def test_book(self):
        self.driver.find_element(AppiumBy.ID, 'com.iBookStar.activityOff:id/go').click()

    @classmethod
    def tearDownClass(cls):
        # cls.driver.close()
        cls.driver.quit()


if __name__ == '__main__':
    unittest.main()
